/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 26727
 * Date: 2025-10-08
 * Time: 16:45
 */
public class TestH5 {
    public static int majorityElement(int[] nums) {
        int cn = nums[0], count = 1;
        for(int i = 1; i < nums.length; i++) {
            if(nums[i] == cn) {
                count++;
            }else {
                count--;
                if(count == 0) {
                    cn = nums[i];
                    count = 1;
                }
            }
        }
        return cn;
    }

    public static void main(String[] args) {
        int[] num = {3,2,3};
        int ret = majorityElement(num);
        System.out.println(ret);
    }
}
